<?php 
class Hd{
    /**
     *
     */
    public static function run(){
        //App目录是否存在
        if (!is_dir("App")){
            //创建目录
            self::createDir();
            //复制目录
            self::copyFile();
        }
        //载入框架核心文件
        self::loadCore();
        //执行应用
        \Hdphp\Libs\App::run();
    }
    private static function loadCore(){
        require "Hdphp/Libs/functions.php";
        require "Hdphp/Org/Smarty/Smarty.class.php";
        //载入
        require "Hdphp/Libs/SmartyView.php";
        //载入总控制器
        require "Hdphp/Libs/Controller.php";
        //载入应用类
        require "Hdphp/Libs/App.php";

    }
    /**
     * 复制目录文件
     */
    private static function copyFile(){
        copy("Hdphp/Common/bootstrap.min.css","Public/bootstrap.min.css");
        copy("Hdphp/Common/success.html","Public/success.html" );
        copy("Hdphp/Common/error.html","Public/error.html" );
        copy("Hdphp/Common/Config.php","App/Home/Config/Config.php");
        copy("Hdphp/Common/IndexController.php","App/Home/Controller/IndexController.php");
        copy("Hdphp/Common/head.html","App/Home/View/view/head.html");
    }
    /**
     * 创建目录
     */
    private static function createDir(){
       $dirArr = array(
           "App/Home/Controller/",
           "App/Home/View/view",
           "App/Home/View/Class",
           "App/Home/Config",
           "Public",
       );
        foreach ($dirArr as $key => $value){
            is_dir($value) || mkdir($value,0777,true);
        }
    }
}
Hd::run();